<!DOCTYPE HTML>
<script>
safari.application.addEventListener("message", handleMessage, false);

function allowContentToLoad(url, nodeName)
{
	if (nodeName === "EMBED" || nodeName === "OBJECT")
		return false;
	return true;
}

function handleMessage(event)
{
	switch (event.name) {
	case "canLoad":
		var data = event.message;
		event.message = allowContentToLoad(data.url, data.nodeName);
		break;
    case "openBackgroundTab":
        var tab = safari.application.activeBrowserWindow.openTab('background');
        tab.url = event.message;
        break;
	}
}
</script>
